package cn.edu.ujn.multiple.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;

import cn.edu.ujn.multiple.model.Product;
import cn.edu.ujn.multiple.service.IProductService;
@Controller
public class ProductController {
	@Autowired
	private IProductService productService;
	
	@GetMapping("/products")
	public String toOrder() {
		return "products";
	}
	
	@PostMapping("/findAllProducts")
	public String findAll(Model m) {
		List<Product> list = productService.findAll();
		m.addAttribute("productList", list);
		return "products";
	}
}
